home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / clipexam / clipexam.frm < prev    next >
Text File  |  1994-05-16  |  7KB  |  231 lines

  1. VERSION 2.00
  2. Begin Form frmClip 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   3  'Fixed Double
  5.    Caption         =   "VB Window Clipping Example"
  6.    ClientHeight    =   4530
  7.    ClientLeft      =   2250
  8.    ClientTop       =   2025
  9.    ClientWidth     =   4560
  10.    Height          =   4935
  11.    Left            =   2190
  12.    LinkTopic       =   "Form1"
  13.    ScaleHeight     =   4530
  14.    ScaleWidth      =   4560
  15.    Top             =   1680
  16.    Width           =   4680
  17.    Begin Frame Frame2 
  18.       BackColor       =   &H00C0C0C0&
  19.       Height          =   615
  20.       Left            =   120
  21.       TabIndex        =   15
  22.       Top             =   3840
  23.       Width           =   4335
  24.       Begin Label Label7 
  25.          AutoSize        =   -1  'True
  26.          BackStyle       =   0  'Transparent
  27.          Caption         =   "Internet: gardiner@cssip.edu.au"
  28.          Height          =   195
  29.          Left            =   720
  30.          TabIndex        =   13
  31.          Top             =   360
  32.          Width           =   2745
  33.       End
  34.       Begin Label Label6 
  35.          AutoSize        =   -1  'True
  36.          BackColor       =   &H00C0C0C0&
  37.          BackStyle       =   0  'Transparent
  38.          Caption         =   "Written by David Gardiner, 13th April, 1994"
  39.          Height          =   195
  40.          Left            =   240
  41.          TabIndex        =   14
  42.          Top             =   120
  43.          Width           =   3690
  44.       End
  45.    End
  46.    Begin Frame Frame1 
  47.       BackColor       =   &H00C0C0C0&
  48.       Caption         =   "Current Clipping"
  49.       Height          =   1935
  50.       Left            =   120
  51.       TabIndex        =   0
  52.       Top             =   120
  53.       Width           =   1935
  54.       Begin Label Label1 
  55.          AutoSize        =   -1  'True
  56.          BackStyle       =   0  'Transparent
  57.          Caption         =   "Left"
  58.          Height          =   195
  59.          Left            =   240
  60.          TabIndex        =   1
  61.          Top             =   360
  62.          Width           =   345
  63.       End
  64.       Begin Label Label2 
  65.          AutoSize        =   -1  'True
  66.          BackStyle       =   0  'Transparent
  67.          Caption         =   "Top"
  68.          Height          =   195
  69.          Left            =   240
  70.          TabIndex        =   2
  71.          Top             =   720
  72.          Width           =   345
  73.       End
  74.       Begin Label Label3 
  75.          AutoSize        =   -1  'True
  76.          BackStyle       =   0  'Transparent
  77.          Caption         =   "Right"
  78.          Height          =   195
  79.          Left            =   240
  80.          TabIndex        =   3
  81.          Top             =   1080
  82.          Width           =   465
  83.       End
  84.       Begin Label Label4 
  85.          AutoSize        =   -1  'True
  86.          BackStyle       =   0  'Transparent
  87.          Caption         =   "Bottom"
  88.          Height          =   195
  89.          Left            =   240
  90.          TabIndex        =   4
  91.          Top             =   1440
  92.          Width           =   600
  93.       End
  94.       Begin Label LeftLabel 
  95.          Alignment       =   1  'Right Justify
  96.          BorderStyle     =   1  'Fixed Single
  97.          Caption         =   "Label1"
  98.          Height          =   225
  99.          Left            =   1080
  100.          TabIndex        =   5
  101.          Top             =   360
  102.          Width           =   615
  103.       End
  104.       Begin Label TopLabel 
  105.          Alignment       =   1  'Right Justify
  106.          BorderStyle     =   1  'Fixed Single
  107.          Caption         =   "Label2"
  108.          Height          =   225
  109.          Left            =   1080
  110.          TabIndex        =   6
  111.          Top             =   720
  112.          Width           =   615
  113.       End
  114.       Begin Label RightLabel 
  115.          Alignment       =   1  'Right Justify
  116.          BorderStyle     =   1  'Fixed Single
  117.          Caption         =   "Label3"
  118.          Height          =   225
  119.          Left            =   1080
  120.          TabIndex        =   7
  121.          Top             =   1080
  122.          Width           =   615
  123.       End
  124.       Begin Label BottomLabel 
  125.          Alignment       =   1  'Right Justify
  126.          BorderStyle     =   1  'Fixed Single
  127.          Caption         =   "Label4"
  128.          Height          =   225
  129.          Left            =   1080
  130.          TabIndex        =   9
  131.          Top             =   1440
  132.          Width           =   615
  133.       End
  134.    End
  135.    Begin CommandButton Command3 
  136.       Caption         =   "&Restore Default"
  137.       Height          =   375
  138.       Left            =   2880
  139.       TabIndex        =   11
  140.       Top             =   1200
  141.       Width           =   1575
  142.    End
  143.    Begin CommandButton Command2 
  144.       Caption         =   "&Clip to Window"
  145.       Height          =   375
  146.       Left            =   2880
  147.       TabIndex        =   10
  148.       Top             =   720
  149.       Width           =   1575
  150.    End
  151.    Begin CommandButton Command1 
  152.       Caption         =   "&Ok"
  153.       Height          =   375
  154.       Left            =   2880
  155.       TabIndex        =   8
  156.       Top             =   120
  157.       Width           =   1575
  158.    End
  159.    Begin Label Label8 
  160.       Alignment       =   2  'Center
  161.       Caption         =   "Public Domain. Please acknowledge use of this 
  162. code if used in your program(s)."
  163.       Height          =   495
  164.       Left            =   120
  165.       TabIndex        =   16
  166.       Top             =   3360
  167.       Width           =   4335
  168.    End
  169.    Begin Label Label5 
  170.       BackColor       =   &H00C0C0C0&
  171.       BackStyle       =   0  'Transparent
  172.       Caption         =   "This little program shows how to use the Windows 
  173. API calls to clip the cursor to the current form. You could clip to any area 
  174. you wanted, though make sure that you restore the clipping to the default 
  175. (whole screen) on exit."
  176.       Height          =   975
  177.       Left            =   120
  178.       TabIndex        =   12
  179.       Top             =   2280
  180.       Width           =   4350
  181.    End
  182. End
  183. Option Explicit
  184.  
  185. Sub Command1_Click ()
  186.  
  187.     ' restore clip to what it was at start up
  188.     Call ClipCursorToScreen
  189.  
  190.     ' exit
  191.     End
  192.  
  193. End Sub
  194.  
  195. Sub Command2_Click ()
  196.  
  197.     ' Clip to form's window
  198.     Call ClipCursorToWindow(frmClip.hWnd)
  199.  
  200.     ' display coordinates
  201.     Call ShowCurrentRect
  202. End Sub
  203.  
  204. Sub Command3_Click ()
  205.  
  206.     ' restore clip to whole screen
  207.     Call ClipCursorToScreen
  208.  
  209.     ' display
  210.     Call ShowCurrentRect
  211. End Sub
  212.  
  213. Sub Form_Load ()
  214.  
  215.     ' display these
  216.     Call ShowCurrentRect
  217. End Sub
  218.  
  219. Sub ShowCurrentRect ()
  220. Dim r As RECT
  221.  
  222.     'get current clipping region
  223.     Call GetClipCursor(r)
  224.  
  225.     LeftLabel.Caption = Str$(r.Left)
  226.     TopLabel.Caption = Str$(r.top)
  227.     RightLabel.Caption = Str$(r.Right)
  228.     BottomLabel.Caption = Str$(r.Bottom)
  229.  
  230. End Sub
  231.